<template>
  <tool-page title="生成随机数" :value="value" @generate="generate" :remark="remark">
    <template #operate>
      范围：
      <InputNumber v-model="start" :min="1" controls-outside/>
      ~
      <InputNumber v-model="end" :min="1" controls-outside/>
      &nbsp;&nbsp;
      小数位：
      <InputNumber v-model="floatLen" :min="0" controls-outside/>
    </template>
    <template #buttonBefore>
      <Button type="success" @click="generate(true)">小数</Button>
    </template>
  </tool-page>
</template>

<script>

export default {
  name: "RandNumber",
  data() {
    return {
      value: '',
      start: 0,
      end: 100,
      floatLen: 2,
      remark: "注：保留小数位逻辑为“四舍五入”"
    }
  },
  methods: {
    generate(float) {
      this.value = this.simpleUtils.randomNumber(this.start, this.end, float).toFixed(this.floatLen);
    }
  },
  created() {
    this.generate();
  }
}
</script>

<style scoped>

</style>
